import java.sql.*;

public class CheckPassword {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url = "jdbc:mysql://db.test1.wcsbapp.com:3306/ChainUp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
            
            try (Connection conn = DriverManager.getConnection(url, "admin", "0YvoGUzwhumnf2KGQvjN")) {
                String query = "SELECT user_name, password, LENGTH(password) as pwd_length FROM sys_user WHERE user_name = 'admin'";
                try (PreparedStatement stmt = conn.prepareStatement(query);
                     ResultSet rs = stmt.executeQuery()) {
                    
                    if (rs.next()) {
                        String password = rs.getString("password");
                        System.out.println("用户名: " + rs.getString("user_name"));
                        System.out.println("密码: " + password);
                        System.out.println("密码长度: " + rs.getInt("pwd_length"));
                        
                        // 检查密码格式
                        if (password.startsWith("$2a$") || password.startsWith("$2b$") || password.startsWith("$2y$")) {
                            System.out.println("密码格式: BCrypt (正确)");
                        } else {
                            System.out.println("密码格式: 非BCrypt (错误)");
                        }
                        
                        // 检查是否有特殊字符
                        System.out.println("密码十六进制: ");
                        for (char c : password.toCharArray()) {
                            System.out.printf("%02x ", (int) c);
                        }
                        System.out.println();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}